home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_05
/
9n05109a
< prev
next >
Wrap
Text File
|
1991-03-22
|
736b
|
44 lines
/*
* ln_seq.cpp - line number sequence implementation
*/
#include <stdio.h>
#include "ln_seq.h"
ln_seq::ln_seq()
{
first = last = 0;
}
ln_seq::ln_seq(unsigned n)
{
first = last = new listnode;
first->number = n;
first->next = 0;
}
void ln_seq::add(unsigned n)
{
listnode *p;
if (first == 0 || last->number != n)
{
p = new listnode;
p->number = n;
p->next = 0;
if (first == 0)
first = p;
else
last->next = p;
last = p;
}
}
void ln_seq::print()
{
listnode *p;
for (p = first; p != 0; p = p->next)
printf("%4d ", p->number);
}